// import { http } from "@/utils/http";
import http from "@/api";


// 设备相关接口
export namespace Equipment {
  // 注册设备请求参数
  export interface RegisterEquipmentRequestDto {
    equipmentType: string;
    equipmentName: string;
    manufacturer: string;
    modelNumber: string;
    serialNumber: string;
    location: string;
  }

  // 设备列表项
  export interface EquipmentListItem extends RegisterEquipmentRequestDto {
    id: string;
    createTime: string;
  }

  // 设备列表响应
  export interface EquipmentListResponse {
    records: EquipmentListItem[];
    total: number;
  }
}

/** 注册设备 */
export const registerEquipment = (params: Equipment.RegisterEquipmentRequestDto) => {
  return http.post<number>("/equipment/register", params);
};

/** 获取设备列表 */
export const getEquipmentList = (params?: any) => {
  return http.get<Equipment.EquipmentListResponse>("/equipment/list", params);
};

/** 编辑设备 */
export const updateEquipment = (params: Partial<Equipment.RegisterEquipmentRequestDto> & { id: string }) => {
  return http.put<void>(`/api/equipment/${params.id}`, params);
};

/** 删除设备 */
export const deleteEquipment = (id: string) => {
  return http.delete<void>(`/equipment/${id}`);
};

/** 批量删除设备 */
export const batchDeleteEquipment = (ids: string[]) => {
  return http.delete<void>("/equipment/batch", { data: { ids } });
}; 